import requests
import json

def test_duckduckgo_server():
    print("测试 DuckDuckGo MCP 服务器...")
    payload = {
        "jsonrpc": "2.0",
        "id": 1,
        "method": "tools/call",
        "params": {
            "name": "search_ticker",
            "arguments": {
                "company_name": "Apple"
            }
        }
    }
    
    response = requests.post(
        "http://localhost:5001",
        json=payload,
        headers={"Content-Type": "application/json"}
    )
    result = response.json()
    print(f"DuckDuckGo 响应: {json.dumps(result, indent=2)}")

def test_yfinance_server():
    print("\n测试 YFinance MCP 服务器...")
    
    payload = {
        "jsonrpc": "2.0",
        "id": 1,
        "method": "tools/call",
        "params": {
            "name": "get_stock_price",
            "arguments": {
                "ticker": "AAPL"
            }
        }
    }
    
    response = requests.post(
        "http://localhost:5002",
        json=payload,
        headers={"Content-Type": "application/json"}
    )
    result = response.json()
    print(f"YFinance 响应: {json.dumps(result, indent=2)}")

if __name__ == "__main__":
    test_duckduckgo_server()
    test_yfinance_server()